package com.aaa.controller;

import com.aaa.entity.MyReturn;
import com.aaa.entity.ResultDiv;
import com.aaa.entity.ViewTestResultFpa;
import com.aaa.service.ViewTestResultFpaService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (ViewTestResultFpa)表控制层
 *
 * @author
 * @since 2022-07-08 10:00:04
 */
@RestController
@RequestMapping("viewTestResultFpa")
public class ViewTestResultFpaController extends BaseController{
    /**
     * 服务对象
     */
    @Resource
    private ViewTestResultFpaService viewTestResultFpaService;
    MyReturn myReturn=new MyReturn();

    @RequestMapping("toShowTestResultFpa.do")
    public ModelAndView toShowTestResultFpa(ModelAndView modelAndView){
        modelAndView.setViewName("viewTestResultFpa");
        return modelAndView;
    }
    @RequestMapping("toReportFormsFpa.do")
    public ModelAndView toReportFormsFpa(ModelAndView modelAndView){
        modelAndView.setViewName("reportFormsFpa");
        return modelAndView;
    }
    /**
     * 分页查询
     *
     * @param viewTestResultFpa 筛选条件
     * @return 查询结果
     */
    @RequestMapping("queryByPage.do")
    public ResponseEntity<Page<ViewTestResultFpa>> queryByPage(ViewTestResultFpa viewTestResultFpa,   Integer page ,Integer limit) {
        PageRequest pageRequest=  PageRequest.of(page-1,limit);
        return ResponseEntity.ok(this.viewTestResultFpaService.queryByPage(viewTestResultFpa, pageRequest));
    }
    /**
     * @create by: feng (zhaixing@163.com)
     * @description: 根据id查询对应信息
     * @create time: 2022/7/15 15:48
     * @param viewTestResultFpa
     * @return MyReturn
     */
    @RequestMapping("queryResultById.do")
    public MyReturn queryResultById(ViewTestResultFpa viewTestResultFpa){
        Map<String, Double> stringDoubleMap = this.viewTestResultFpaService.queryRequestById(viewTestResultFpa);
        myReturn.setData(stringDoubleMap);
        return getSuccessResult(myReturn);
    }
    /**
     * @create by: feng (zhaixing@163.com)
     * @description: 查询所有数据 报表统计
     * @create time: 2022/7/15 16:17
     * @param
     * @return MyReturn
     */
    @RequestMapping("colorCount.do")
    public MyReturn colorCount(){
        Map<String, Integer> map = this.viewTestResultFpaService.queryAllPlanFpa();
        myReturn.setData(map);
        return getSuccessResult(myReturn);
    }
    /**
     * @create by: feng (zhaixing@163.com)
     * @description: 删除
     * @create time: 2022/7/22 20:10
     * @param testerId
     * @return
     */
    @RequestMapping("deleteResultFpa.do")
    public MyReturn deleteResultFpa(String testerId){
        boolean b = this.viewTestResultFpaService.deleteResultById(testerId);
        if (b) {
            return getSuccessResult(myReturn);
        }
        return getFailResult(myReturn);
    }
    @RequestMapping("pullFpa.do")
    public MyReturn pullFpa(){
        List<ViewTestResultFpa> viewTestResultFpa = this.viewTestResultFpaService.queryAllResultFpa();
        myReturn.setData(viewTestResultFpa);
        return getSuccessResult(myReturn);
    }

    @RequestMapping("div.do")
    public MyReturn resultDiv(Integer id){
        List<ResultDiv> resultDivs = viewTestResultFpaService.queryAllResultDiv(id);
        myReturn.setData(resultDivs);
        return getSuccessResult(myReturn);
    }


}

